package nz.ac.massey.groupproject.ecs2;

// An entity must not have WallTag and LinearBouncebackMotion at the same time
public class LinearBouncebackMotion implements ECSComponent {
	public final int speed2;       // speed squared

	public int vx;
	public int vy;

	public LinearBouncebackMotion(int vx_, int vy_) {
		int s2 = vx_*vx_ + vy_*vy_;

		// TODO clip, instead of reject
		if (s2 <= 50 * 50) {
			vx = vx_;  vy = vy_;
			speed2 = s2;
		} else {
			speed2 = vx = vy = 0;
		}
	}
}
